package com.ruoyi.comment.service.impl;

import com.ruoyi.comment.domain.SysComment;
import com.ruoyi.comment.mapper.SysCommentMapper;
import com.ruoyi.comment.service.ISysCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SysCommentServiceImpl implements ISysCommentService {

    @Autowired
    private SysCommentMapper commentMapper;

    @Override
    public void saveComment(SysComment comment) {
        // 设置创建时间
        comment.setCreateTime(new Date());
        commentMapper.insert(comment);
    }

    @Override
    public List<SysComment> getCommentsByOrderId(Long orderId) {
        return commentMapper.selectByOrderId(orderId);
    }

    @Override
    public void deleteCommentById(Long commentId) {
        commentMapper.deleteById(commentId);
    }

    @Override
    public SysComment getCommentById(Long commentId) {
        return commentMapper.selectById(commentId);
    }

}